package cn.wolfcode.car.service.impl;

import cn.wolfcode.car.domain.Business;
import cn.wolfcode.car.mapper.BusinessMapper;
import cn.wolfcode.car.qo.BusinessQueryObject;
import cn.wolfcode.car.service.IBusinessService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class BusinessServiceImpl implements IBusinessService {

    @Autowired
    private BusinessMapper businessMapper;

    @Override
    public int delete(Long id) {
        return businessMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int save(Business record) {
        return businessMapper.insert(record);
    }

    @Override
    public Business get(Long id) {
        return businessMapper.selectByPrimaryKey(id);
    }

    @Override
    public PageInfo<Business> list(BusinessQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        List<Business> list = businessMapper.selectForPage(qo);
        return new PageInfo<>(list);
    }

    @Override
    public List<Business> listAll() {
        return businessMapper.selectAll();
    }

    @Override
    public int update(Business record) {
        return businessMapper.updateByPrimaryKey(record);
    }

    @Override
    public Business getMainStore() {
        return businessMapper.getMainStore();
    }


}
